package com.springboot_jade.study.config;

import de.neuland.jade4j.JadeConfiguration;
import de.neuland.jade4j.spring.template.SpringTemplateLoader;
import de.neuland.jade4j.spring.view.JadeViewResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JadeConfig {

    @Bean
    public SpringTemplateLoader springTemplateLoader() {
        SpringTemplateLoader stl = new SpringTemplateLoader();
        stl.setEncoding("UTF-8");
        stl.setSuffix(".jade");
        stl.setBasePath("classpath:/templates/");
        return stl;
    }

    @Bean
    public JadeConfiguration jadeConfiguration() {
        JadeConfiguration jc = new JadeConfiguration();
        jc.setTemplateLoader(springTemplateLoader());
        jc.setCaching(false);
        return jc;
    }

    @Bean
    public JadeViewResolver jadeViewResolver() {
        JadeViewResolver jvr = new JadeViewResolver();
        jvr.setConfiguration(jadeConfiguration());
        jvr.setSuffix(".jade");
        return jvr;
    }
}
